#!/bin/sh

source /etc/certificate-services.conf


is_jboss_running(){
    checkjboss=`/bin/ps -ef | grep '${JBOSS_HOME}/bin/run.sh' | grep -v grep`
    if [ "x${checkjboss}" != "x" ] ; then
        return 0
    else
        return 1
    fi
    
}

is_jboss_running
if [ $? -eq 0 ] ; then
        echo "jboss is running please stop it first"
        exit
fi

if [ ! -d /var/log/jboss ] ; then
        mkdir /var/log/jboss
fi


if [ -d ${JBOSS_HOME}/server/default/log/ ] ; then

  for file in $(find ${JBOSS_HOME}/server/default/log/ -type f) ; do
        mv ${file} /var/log/jboss/

  done
  rmdir ${JBOSS_HOME}/server/default/log/
fi
        
ln -s /var/log/jboss/ ${JBOSS_HOME}/server/default/log
chown -R jboss.jboss /var/log/jboss
chmod 700 /var/log/jboss

